<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order', function (Blueprint $table) {
            $table->increments('id')->comment('订单表');
            $table->string('trade_id', 32)->comment('订单ID');
            $table->integer('user_id')->unsigned()->comment('用户ID');
            $table->integer('related_id')->unsigned()->comment('商品ID');
            $table->decimal('total', 8, 2)->unsigned()->default(0)->comment('总价');
            $table->tinyInteger('status')->unsigned()->default(0)->comment('状态：0-未支付，1-支付成功，2-超时');
            $table->tinyInteger('type')->unsigned()->default(1)->comment('订单类型');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order');
    }
}
